package com.lc.hongtai.conn;

import android.util.Log;

import com.google.gson.Gson;
import com.zcx.helper.http.AsyCallBack;
import com.zcx.helper.http.note.HttpInlet;

import org.json.JSONObject;

import java.util.List;

/**
 * Created by Administrator on 4/25/2016.
 */
@HttpInlet("index/find")
public class JsonEconomics extends HYAsyPost<JsonEconomics.Info> {

    public String access_token;
    public int type;

    public JsonEconomics(String access_token, int type, AsyCallBack<Info> asyCallBack) {
        super(asyCallBack);
        this.access_token = access_token;
        this.type = type;
    }

    @Override
    protected Info parser(JSONObject object) throws Exception {
        Gson gson = new Gson();

        Log.d(object.toString(), "77777777777777777");

        JsonEconomics.Info info = new JsonEconomics.Info();
        info = gson.fromJson(object.toString(), JsonEconomics.Info.class);
        return info;

    }

    /*   @Override
        protected Info parser(JSONObject object) {
            Log.d(object.toString(), "==============================");
            Info info = null;
            if (object.optString("status").equals("1")) {
                info = new Info();
                Info.Page page = new Info.Page();
                JSONObject jsonObject = object.optJSONObject("page");
                page.nowPage = Integer.parseInt(jsonObject.optString("nowPage"));
                page.totalPages = Integer.parseInt(jsonObject.optString("totalPages"));
                page.pageSize = Integer.parseInt(jsonObject.optString("pageSize"));
                page.totalRows = Integer.parseInt(jsonObject.optString("totalRows"));
                info.page = page;
                JSONArray array = object.optJSONArray("list");
                List<Info.ListContent> list = new ArrayList();
                for (int i = 0; i < array.length(); i++) {
                    JSONObject object1 = array.optJSONObject(i);
                    Info.ListContent listContent = new Info.ListContent();
                    listContent.id = object1.optString("id");
                    listContent.transfer_price = object1.optString("transfer_price");
                    listContent.money = object1.optString("money");
                    listContent.total_period = object1.optString("total_period");
                    listContent.period = object1.optString("period");
                    listContent.borrow_name = object1.optString("borrow_name");
                    listContent.borrow_interest_rate = object1.optString("borrow_interest_rate");
                    listContent.status = object1.optString("status");

                    list.add(listContent);
                }
                info.list = list;

                TOAST = object.optString("tips");

                return info;

            }

            TOAST = object.optString("tips");

            return null;
        }
    */
    public static class Info {

        public List<ListContent> list;

        public Page page;

        public List<Banner> banner;

        public List<Article> article;

        public static class Article {
            public String title;
            public String id;
            public String art_info;
            public String art_img;
        }


        public static class Banner {
            public String img;
            public String url;
            public String title;

        }



        public static class Page {
            public int nowPage;
            public int totalPages;
            public int pageSize;
            public int totalRows;
        }

        public static class ListContent {
            public String id;
            public String transfer_price;
            public String money;
            public String total_period;
            public String period;
            public String borrow_name;
            public String borrow_interest_rate;
            public String status;
        }

    }
}
